//
//  WCMeetingtimeManager.m
//  WC
//
//  Created by wsj2015 on 15/10/20.
//  Copyright (c) 2015年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCMeetingtimeManager.h"

@implementation WCMeetingtimeManager
{
    NSTimer *_timer;
    NSInteger _time;
 
}

- (instancetype)initWithTime:(NSInteger)time
{
    if (self =[super init]) {
        [self timeDecreasingTimer:time];
    }
    return self;
}

- (void)timeDecreasingTimer:(NSInteger)time
{
    _time =time;
    if (!_timer) {
        _timer =[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updataTimer) userInfo:nil repeats:YES];
    }
 
}
- (void)updataTimer
{
    if (_time == 0) {
        [_timer invalidate];
        _timer =nil;
        if (self.timeOverBlock) {
            self.timeOverBlock();
        }
        
    }
    _time--;
    
}
- (NSInteger)getCurrentLeftTime
{
    return _time;
    
}
- (void)dealloc
{
    [_timer invalidate];
    _timer =nil;

}
@end
